﻿using System;
using ParticlePlayground;

namespace UnityEngine
{
	// Token: 0x020000F5 RID: 245
	public class PlaygroundProceduralMeshTarget : MonoBehaviour
	{
		// Token: 0x0600056C RID: 1388 RVA: 0x000210D8 File Offset: 0x0001F2D8
		public virtual void Start()
		{
			IsoSphere.CreateMesh(base.gameObject, this.proceduralMeshRecursion, this.proceduralMeshSize, false);
			if (this.particles != null)
			{
				this.manipulator = ParticlePlayground.PlaygroundC.ManipulatorObject(base.gameObject.transform, this.particles);
				this.manipulator.type = ParticlePlayground.MANIPULATORTYPEC.Property;
				this.manipulator.property.type = ParticlePlayground.MANIPULATORPROPERTYTYPEC.MeshTarget;
				this.manipulator.property.meshTarget.gameObject = base.gameObject;
				this.manipulator.property.transition = ParticlePlayground.MANIPULATORPROPERTYTRANSITIONC.Linear;
			}
			else
			{
				UnityEngine.Debug.Log("You must assign a Particle Playground system to this script.", base.gameObject);
			}
		}

		// Token: 0x0600056D RID: 1389 RVA: 0x0002118C File Offset: 0x0001F38C
		public virtual void Update()
		{
			this.particles.particleSystemTransform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10f));
			this.manipulator.size = this.manipulatorSize;
			this.manipulator.strength = this.manipulatorStrength;
			base.transform.RotateAround(Vector3.zero, Vector3.up, -this.rotationSpeed * Time.deltaTime);
		}

		// Token: 0x0600056E RID: 1390 RVA: 0x0002121C File Offset: 0x0001F41C
		public virtual void OnGUI()
		{
			GUI.Box(new Rect(0f, 0f, 220f, 125f), "Manipulator");
			GUI.Label(new Rect(10f, 30f, 200f, 30f), "Strength: " + this.manipulatorStrength.ToString("f1"));
			this.manipulatorStrength = GUI.HorizontalSlider(new Rect(10f, 55f, 200f, 30f), this.manipulatorStrength, 0f, 30f);
			if (GUI.Button(new Rect(10f, 85f, 200f, 30f), "Transition: " + this.manipulator.property.transition.ToString()))
			{
				if (this.manipulator.property.transition == ParticlePlayground.MANIPULATORPROPERTYTRANSITIONC.Linear)
				{
					this.manipulator.property.transition = ParticlePlayground.MANIPULATORPROPERTYTRANSITIONC.Lerp;
				}
				else
				{
					this.manipulator.property.transition = ParticlePlayground.MANIPULATORPROPERTYTRANSITIONC.Linear;
				}
			}
			GUI.Box(new Rect(240f, 0f, 220f, 125f), "Turbulence");
			GUI.Label(new Rect(250f, 30f, 200f, 30f), "Strength: " + this.particles.turbulenceStrength.ToString("f1"));
			this.particles.turbulenceStrength = GUI.HorizontalSlider(new Rect(250f, 55f, 200f, 30f), this.particles.turbulenceStrength, 0f, 50f);
			if (GUI.Button(new Rect(250f, 85f, 200f, 30f), "Type: " + this.particles.turbulenceType.ToString()))
			{
				if (this.particles.turbulenceType == ParticlePlayground.TURBULENCETYPE.Perlin)
				{
					this.particles.turbulenceType = ParticlePlayground.TURBULENCETYPE.Simplex;
				}
				else
				{
					this.particles.turbulenceType = ParticlePlayground.TURBULENCETYPE.Perlin;
				}
			}
			GUI.Box(new Rect((float)(Screen.width - 220), 0f, 220f, 125f), "Mesh");
			GUI.Label(new Rect((float)(Screen.width - 210), 30f, 200f, 30f), "Rotation Speed: " + this.rotationSpeed.ToString("f1"));
			this.rotationSpeed = GUI.HorizontalSlider(new Rect((float)(Screen.width - 210), 55f, 200f, 30f), this.rotationSpeed, -100f, 100f);
			if (GUI.Button(new Rect((float)(Screen.width - 210), 85f, 200f, 30f), "Subdivide x" + this.subdivisionFactor.ToString()))
			{
				this.subdivisionFactor++;
				this.subdivisionFactor %= 4;
				if (this.subdivisionFactor == 0)
				{
					IsoSphere.CreateMesh(base.gameObject, 1, this.proceduralMeshSize, false);
				}
				else
				{
					SubdivideMesh.Subdivide(base.gameObject.GetComponent<MeshFilter>().mesh);
				}
				this.UpdateTargetManipulator();
			}
		}

		// Token: 0x0600056F RID: 1391 RVA: 0x00021588 File Offset: 0x0001F788
		public virtual void UpdateTargetManipulator()
		{
			this.manipulator.property.meshTarget.Update();
		}

		// Token: 0x04000583 RID: 1411
		public ParticlePlayground.PlaygroundParticlesC particles;

		// Token: 0x04000584 RID: 1412
		public float manipulatorSize = 100f;

		// Token: 0x04000585 RID: 1413
		public float manipulatorStrength = 20f;

		// Token: 0x04000586 RID: 1414
		public float proceduralMeshSize = 3f;

		// Token: 0x04000587 RID: 1415
		public int proceduralMeshRecursion = 1;

		// Token: 0x04000588 RID: 1416
		public float rotationSpeed = 10f;

		// Token: 0x04000589 RID: 1417
		public ParticlePlayground.ManipulatorObjectC manipulator;

		// Token: 0x0400058A RID: 1418
		public int subdivisionFactor;
	}
}
